package com.slz3.business.module.afterSaleManagement.aftApplyOrderLine;

import com.slz3.business.frame.route.Pattern;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicate;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

public class AftApplyOrderLineRouter {

    private static RequestPredicate JSON_UTF8 = accept(MediaType.APPLICATION_JSON_UTF8);

    public static RouterFunction<ServerResponse> funs(AftApplyOrderLineHandler handler) {
        return route(POST(Pattern.ADD).and(JSON_UTF8), handler::add)
                .andRoute(PUT(Pattern.DELETE).and(JSON_UTF8), handler::delete)
                .andRoute(PUT(Pattern.MODIFY).and(JSON_UTF8), handler::modify)
                .andRoute(GET(Pattern.INFO), handler::info)
                .andRoute(GET(Pattern.LIST), handler::list)
                .andRoute(GET(Pattern.CHOICE), handler::choice)
                .andRoute(GET(Pattern.FIND_BY_SER_AFTER_SALE_ID),handler::findBySerAfterSaleId)
                .andRoute(PUT(Pattern.AUDIT_SUBMIT).and(JSON_UTF8), handler::auditSubmit)
                .andRoute(PUT(Pattern.AUDIT).and(JSON_UTF8), handler::audit)
                .andRoute(PUT(Pattern.AUDIT_REJECT).and(JSON_UTF8), handler::auditReject)
                .andRoute(PUT(Pattern.USING_ENABLE).and(JSON_UTF8), handler::usingEnable)
                .andRoute(PUT(Pattern.USING_DISABLE).and(JSON_UTF8), handler::usingDisable)
                ;
    }

}
